package jsave.action;

import java.io.File;

import jsave.exception.JSaveArretSauvegarde;
import jsave.exception.JSaveException;
import jsave.tree.FileNode;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

public class ActionIgnorer extends Action {

	private static final Logger log = Logger.getLogger(ActionIgnorer.class);

	public ActionIgnorer(int typeAction) {

		if (typeAction == Action.ACTION_A || typeAction == Action.ACTION_B
				|| typeAction == Action.ACTION_C
				|| typeAction == Action.ACTION_D) {
			this.typeAction = typeAction;
		} else {
			log.log(Level.ERROR, "ERREUR - Le type d'action '" + typeAction
					+ "' ne correspond pas a l'action 'ActionIgnorer' ");
		}
	}

	public void executer(File s, File d) throws JSaveArretSauvegarde {

		log.log(Level.INFO, "IG - " + s.getPath());
		if (s.isDirectory()) {
			nbDossiersIgnores++;
		} else {
			nbFichiersIgnores++;
		}
	}

	public String getNom() {
		return "IGNORER";
	}

	@Override
	public void executer(String sourcePath, String destinatinoPath, FileNode n)
			throws JSaveException {
		log.log(Level.INFO, "IG - " + destinatinoPath+File.separator+n.getRelativePath());
	}
}
